#ifndef _SOM_H_
#define _SOM_H_

#include <string>
#include <system/Arquivo.h>
#include "Sinal_1D.h"
#include <windows.h>
#include <mmsystem.h>

#define CANAL_L(x) ((signed short)( (x)     &0x0000FFFF))
#define CANAL_R(x) ((signed short)(((x)>>16)&0x0000FFFF))

#define LR(L,R) ((((R)<<16)&0xFFFF0000) | ((L)&0x0000FFFF))


typedef struct tagDadosPlay {
    HWAVEOUT handleOut;
    WAVEHDR  whOut;
    PWAVEHDR pwhOut;
} DADOSPLAY, *PDADOSPLAY;


DWORD WINAPI ThreadPlay(LPVOID lpParam);


class Som : public Arquivo
{

public:

    Som();
    Som(int n);
    Som(std::string strNomeDoArquivo);

    bool Abrir();
    bool Abrir(std::string strNomeDoArquivo);

    void Play();
    void Pause();
    void Stop();

    int& operator[](int pos);

    Sinal_1D* Sinal();

private:

    HANDLE       m_hThreadPlay;
    WAVEFORMATEX m_wfx;
    MMRESULT     m_status;
    HWAVEOUT     m_handleOut;
    WAVEHDR      m_whOut;

    int  m_nCanais;
    int  m_nBits;
    int  m_nTaxa;

    int* m_pStream;
    int  m_nTamanho;

};


#endif  // _SOM_H_
